package commons.cloud;


/**
 * These are the possible values for machine types, currently based on amazon EC2 instance types.
 * 
 * @author David Candeia - davidcmm@lsd.ufcg.edu.br
 * @author Ricardo Ara&uacute;jo Santos - ricardo@lsd.ufcg.edu.br
 */
public enum MachineType{

	T1_MICRO(2, 1),
	M1_SMALL(1, 1), 
	C1_MEDIUM(2.5, 2),
//	M2_XLARGE(3.25, 2),
//	M1_LARGE(2, 2), 
	M1_LARGE(2, 4), 
//	M1_XLARGE(2, 4), 
//	M2_2XLARGE(3.25, 4), M2_4XLARGE(3.25, 4),
	M1_XLARGE(2, 8), 
	C1_XLARGE(2.5, 8);
	
	private final double ec2Units;
	private final int totalCapacity;
	
	/**
	 * Default constructor.
	 * @param clockRateInGHz Core relative power in Ec2 Units
	 * @param totalCapacity Number of identical cores: ec2 units x virtual cores 
	 */
	private MachineType(double ec2Units, int totalCapacity) {
		this.ec2Units = ec2Units;
		this.totalCapacity = totalCapacity;
	}

	/**
	 * @return the relative power of each core.
	 */
	public double getEC2Units() {
		return ec2Units;
	}

	/**
	 * @return the number of cores
	 */
	public int getTotalCapacity() {
		return totalCapacity;
	}
	
	public double getVirtualCores(){
		return totalCapacity / ec2Units;
	}

	/**
	 * @return Relative power of machine types
	 */
	public int getRelativePower() {
		return (int) Math.ceil(getEC2Units());
	}
};
